﻿using Contract.Infrastructure.Repository;
using Contract.WebApi.Application.Commands;
using MediatR;

namespace Contract.WebApi.Application.CommandHandler
{
    public class DelCYContractCommandHandler : IRequestHandler<DelCYContractCommands, int>
    {
        private readonly IRepository<Domain.Contract> repository;

        public DelCYContractCommandHandler(IRepository<Domain.Contract> repository)
        {
            this.repository = repository;
        }

        public async Task<int> Handle(DelCYContractCommands request, CancellationToken cancellationToken)
        {
            var info = await repository.GetAsync(request.Id);
            info.IsDel = true;
            info.UpdateDate = DateTime.Now;
            var ind = await repository.UpdateAsync(info);
            return ind;
        }
    }
}
